<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]--><nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
	<span class="c-gray en">&gt;</span>
	业务管理
	<span class="c-gray en">&gt;</span>
	运输管理
	 
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container" id="app">
	<div class="text-c">
		
		<span id="fileId" style="display:none" class="btn-upload form-group">
			<input class="input-text upload-url" type="text" name="uploadfile" id="uploadfile" readonly nullmsg="请添加附件！" style="width:200px">
			<a href="javascript:void();" class="btn btn-primary radius upload-btn"><i class="Hui-iconfont"></i> 浏览文件</a>
			<input type="file" multiple name="file" class="input-file" id="file">
		</span>
		<a id="formUpload" style="display:none" href="javascript:uploadReportXls();" class="btn btn-primary radius upload-btn"><i class="Hui-iconfont">&#xe642;</i> 上传</a>
		
		
		分公司:
		<span class="select-box inline">
		<select class="select" id="comId" name="comId">
			<option value="">请选择分公司</option>
		
		</select>
		</span>
		票务室:
		<span class="select-box inline">
		<select class="select" id="toId" name="toId">
			<option value="">请选择票务室</option>
		</select> 
		</span>
		运输计划:
		<span class="select-box inline">
		<select class="select" id="workPlan" name="workPlan">
			<option value="">请选择</option>
		</select> 
		</span>
		<button name="" id="" onclick="queryTable();" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i>查询</button>
		<button name="" style="display:none;" id="updateByChe" onclick="updateByChecked();" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i></button>
		<button name="" style="display:none" id="addByComOff" onclick="addByCompanyOffice();" class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe600;</i>新增</button>
		<button name="" style="display:none" id="export" onclick="excelExport();" class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe600;</i>导出</button>
		<button name="" style="display:none" id="delByChe" onclick="delByNumAndWorkPlanTitle();" class="btn btn-danger radius" type="submit"><i class="Hui-iconfont">&#xe6e2;</i>删除</button>
		<button name="" style="display:none" id="process" onclick="processOnclick();" class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe600;</i>流程参考</button>
		
		
		
	</div>
	<div class="mt-20">
	<!-- 	<table id="list" class="table table-border table-bordered table-hover table-bg table-sort">
		</table> -->
		
		<table id="list" class="table table-border table-bordered table-hover table-bg table-sort">
			<thead  id="theadId">
			</thead>
			<tbody id="tbodyId" >	
			</tbody>  
		</table>
		
	</div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script>  <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="js/jquery.base64.js"></script>
<script type="text/javascript" src="js/jquery.table2excel2.js"></script>

<script type="text/javascript" src="js/vue.js" charset="utf-8"></script>
<style>
	
	.trclass{
		 white-space: nowrap; 
	}
	
</style>
<script type="text/javascript">


</script>

	
<script type="text/javascript">
var workPlanTitleUrl =  reportForm+'workPlanTitle/';
//$("#list").attr("style", "display:none;");
var dataTable;
var userinfo =getUserInfo();
var groups =userinfo.groups
var stepType ="";//"2"; 集团看审核中和审核成功的 不等于0的 
var table ;
$(function(){
	var comId;
	var toId;
	
	//var username ="admin"//window.localStorage.getItem("user_name");
	var ccc =window.localStorage.getItem("authorities");  
	var username =userinfo.username;
	var myArray;
	stepType="gjjt"
	// for(var i = 0;i<groups.length;i++){
	// 	if("6"==groups[i].id){
	// 		stepType="dtwl"
	// 	}else if("20"==groups[i].id){
	// 		stepType="bjyh"
	// 	}else{
	// 	}
	// }
	
	
	
	
		$.ajax({
			type: 'get',
			url: report_service+'/getAllCompany',
			/* beforeSend: function (request) {
							request.setRequestHeader("Authorization", "Bearer " + getToken());
						}, */
			dataType: 'json',
			async: false,
			success: function(data){
				var list =  eval('(' + data.list + ')');
				for(var i = 0;i<list.length;i++){
					$("#comId").append("<option value='"+list[i].companyid+"'>"+list[i].companyname+"</option>");				
				}
			},
			error: function(data){
				console.log(data.msg);
			}
		});
		
		$.ajax({
			type: 'get',
			url: report_service+'/getUserByname',
			data:{
				"username": username
			},
			async: false,
			/* beforeSend: function (request) {
							request.setRequestHeader("Authorization", "Bearer " + getToken());
						}, */
			dataType: 'json',
			success: function(data){
				var list =  eval('(' + data.list + ')');
				if(list[0].officeId.indexOf("1")==0){
					$("#comId").val(list[0].companyId);
					comId = list[0].companyId;
					
					$.ajax({
						type: 'get',
						url: report_service+'/getTicktOfficeByCom',
						/* beforeSend: function (request) {
										request.setRequestHeader("Authorization", "Bearer " + getToken());
									}, */
						data:{
							"comId":comId
						},
						cache:false,    
						dataType:'json',
						async: false,
						success: function(data){
							stepType="office";
							//var list = data.list;
							$("#fileId").attr("style", "display:none;");
							$("#formUpload").attr("style", "display:none;");
							$("#updateByChe").attr("style", "display:none;");
							$("#addByComOff").attr("style", "display:none;");
							
							var list =  eval('(' + data.list + ')');
							for(var i=0;i<list.length;i++){
								var option = '<option value="'+list[i].toiid+'">'+list[i].toiname+'</option>';
								$("#toId").append(option);
							}
						},
						error:function(){
							alert("请求失败");
						}
					});
					$("#toId").val(list[0].officeId);
					toId = list[0].officeId;
					$("#comId").attr("disabled","disabled");
					$("#toId").attr("disabled","disabled");
				}
				if(list[0].officeId.indexOf("1") == -1  && list[0].companyId.indexOf("1")==0 ){
					$("#comId").val(list[0].companyId);
					comId = list[0].companyId;
					$.ajax({
						type: 'get',
						url: report_service+'/getTicktOfficeByCom',
						/* beforeSend: function (request) {
										request.setRequestHeader("Authorization", "Bearer " + getToken());
									}, */
						data:{
							"comId":comId
						},
						cache:false,    
						dataType:'json',
						async: false,
						success: function(data){
							stepType="company";
							$("#fileId").attr("style", "display:blank;");
							$("#formUpload").attr("style", "display:blank;");
							$("#updateByChe").attr("style", "display:blank;");
							$("#addByComOff").attr("style", "display:blank;");
							//var list = data.list;
							var list =  eval('(' + data.list + ')');
							for(var i=0;i<list.length;i++){
								var option = '<option value="'+list[i].toiid+'">'+list[i].toiname+'</option>';
								$("#toId").append(option);
							}
						},
						error:function(){
							alert("请求失败");
						}
					});
					$("#comId").attr("disabled","disabled");
				}
				
				
				
				
			},
			error: function(data){
				console.log(data.msg);
			}
		});
	
	

	for(var i = 0;i<groups.length;i++){
		if("6"==groups[i].id){
			stepType="dtwl"
		}else if("20"==groups[i].id){
			stepType="bjyh"
		}else{
		}
	}
	var iconfont = document.getElementsByClassName("Hui-iconfont")
	$("#updateByChe").attr("style", "display:blank;");
	if("gjjt"==stepType){
		$("#fileId").attr("style", "display:blank;");
		$("#formUpload").attr("style", "display:blank;");
		$("#addByComOff").attr("style", "display:blank;");//集团新增按钮
		$("#delByChe").attr("style", "display:none;");//集团删除按钮
		// $("#addByComOff").attr("style", "display:blank;");
		// $("#delByChe").attr("style", "display:blank;");
		$("#export").attr("style", "display:blank;");
		$("#process").attr("style", "display:blank;");
		
		 //导出按钮
		iconfont[5].innerHTML="批量审核"
	}else if("dtwl"==stepType){
		$("#process").attr("style", "display:blank;");
		console.log("wuliu")
		iconfont[5].innerHTML="批量审核"
	}else if("bjyh"==stepType){
		$("#process").attr("style", "display:blank;");
		iconfont[5].innerHTML="批量审核"
	}else if("office"==stepType){
		$("#updateByChe").attr("style", "display:none;");
	}else{
		iconfont[5].innerHTML="批量提交"
		$("#process").attr("style", "display:blank;");
	}
	
	var comId ="" //$("#comId").val();
	var step ="" //"2";
	var titleName = ""
	$.ajax({
		type: 'get',
		url: workPlanTitleUrl+'/getWorkPlanTitleByCompanyIdAndStep',
		data:{
			"companyId": comId,
			"step":step,
			"titleName":titleName
		},
		dataType: 'json',
		async: false,
		success: function(data){
			var list = 	data.workPlanTitle;
			if(list=="0"){
				return;
			}else{
				var titleName = list[0].titleName;
				titleName=titleName.substring(0,4)+"年"+titleName.substring(4,6)+"月";
				$("#workPlan").append("<option  selected = 'selected' value='"+list[0].titleName+"'>"+titleName+"</option>");	
				
				for(var i = 1;i<list.length;i++){
					titleName=list[i].titleName.substring(0,4)+"年"+list[i].titleName.substring(4,6)+"月";
					$("#workPlan").append("<option value='"+list[i].titleName+"'>"+titleName+"</option>");				
				}
			}
			//console.log("====="+JSON.stringify(data.workPlanTitle))
			 //var list =  eval('(' + data.workPlanTitle + ')');
			
		},
		error: function(data){
			console.log(data.msg);
		}
	});
	queryTable();
})



function uploadReportXls(){
 	var formData = new FormData();
	var comId = $("#comId").val();
	formData.append('file', $("#file")[0].files[0]);
	for(var i = 0;i<groups.length;i++){
		console.log(JSON.stringify(groups[i]))
		if("1"==groups[i].id){
			comId = "admin";
		}else if("2"==groups[i].id){
			comId = "gjjt";
		}else{
		}
		
	}
	formData.append("comId",comId);
	$.ajax({
		url:reportForm+'workPlan/workPlanFileExcel',
		type:'POST',
		data: formData,
		contentType: false,
		processData: false,
		success:function(data){
			console.log(data.msg)
			if(data.msg=="0"){
				alert('重复上传');
				
			}else {
				alert('成功');
				 window.location.reload();
			}
		}
	}); 
	
	}


function queryTable(){

	console.log(JSON.stringify(userinfo))
	var comId = $("#comId").val();
	var toId =$("#toId").val();
	var workPlan =$("#workPlan").val();
	
	
	
	for(var i = 0;i<groups.length;i++){
		if("6"==groups[i].id){
			stepType="dtwl"
		}else if("20"==groups[i].id){
			stepType="bjyh"
		}else{
		}
	}
	
    $.ajax({
    	type: 'post',
    	url:reportForm+'workPlan/queryAll',
    	data: {
			companyId:comId,
			officeId:toId,
			step:stepType,
			"titleName":workPlan
    	},
    	dataType: 'json',
    	success: function(data){
		
		var titleNums=""; 
		var workPlanTitle = data.workPlanTitle;
		var workPlanList = data.WorkPlanList;
		var columns=[
			{data: 'id',  "defaultContent": "" },
			{data: 'serialNumber',  "defaultContent": "" ,"className":"trclass"},
			{data: 'companyName',  "defaultContent": "","className":"trclass" },
			{data: 'officeName',  "defaultContent": "" ,"className":"trclass"},
			{data: '',  "defaultContent": "" ,"className":"trclass"},
			//{data: 'receivablesTime',  "defaultContent": ""},
			//{data: 'rechargePointTransportationPlan',  "defaultContent": "" },
			{data: 'rallyingPoint',  "defaultContent": "" ,"className":"trclass"},
			
		    ]
			var titleName =  workPlanTitle.titleName;
			var dayT = new Date(titleName.substring(0,4),titleName.substring(4,6),0);
			titleNums="31"//dayT.getDate();
			var day = "day";
			for(var i = 1;i<=titleNums;i++){
				day = "day"+i;
				var tit = { "data": day,"defaultContent": "0","className":"trclass" };
				columns.push(tit);
			}
		
			var receivablesTime = 	{data: 'receivablesTime',  "defaultContent": "" ,"className":"trclass"};
			columns.push(receivablesTime);
			
			var remarks = 	{data: 'remarks',  "defaultContent": "" ,"className":"trclass"};
			columns.push(remarks)
			// var remarkscompany = 	{data: 'receivablesTimeMonth',  "defaultContent": "" };
			// columns.push(remarkscompany)
			var update = 	{data: '',  "defaultContent": "","className":"trclass" };
			columns.push(update)
				console.log(titleNums)
    			table =  $('#list').DataTable( {
    					   data: data.WorkPlanList,
    					  // data2: data.companyList,
    					   //使用对象数组，一定要配置columns，告诉 DataTables 每列对应的属性
    					   //data 这里是固定不变的，name，position，salary，office 为你数据里对应的属性
    					   destroy:true,
						   columns:columns,
						   aLengthMenu: [200],
    					columnDefs: [
							{
							   "targets": 0,//
							   "data": null,
							   render: function(data, type, row, meta) {
									return '<input  class="check_item"    value="'+row.serialNumber+'" name="qrcodeid" type="checkbox" />'
									
							   }
							}  ,
    						{
    						   "targets": 4,//
    						   "data": null,
    						   render: function(data, type, row, meta) {
    								 if("1"==row.someoneSellTicket){
    									return '<td>纯有人售</td>'								   
    								 }else if("1"==row.bleanTickets){
    									return '<td>混编</td>'
    								 }else if("1"==row.unsoldTickets){
    									return '<td>纯无人售</td>'
    								 }else if("1"==row.rechargePoint){
    									return '<td>充值点</td>'
    								 }else{
    									return ''
    								 }
    						   }
    						}  ,
							
							{
							   "targets": -1,//
							   "data": null,
							   render: function(data, type, row, meta) {
								   var titleName  = workPlanTitle.titleName;
								   localStorage.setItem("titleName",titleName);
								   localStorage.setItem("stepType",stepType);
								    //  00 公司编辑 
								    //  01 集团审核
								    //  02 物流审核    
								    //  03 银行审核 
								    //  04 发布      
								    
								    //  97 集团不通过
								    //  98 物流不通过
								    //  99 银行不通过
								   if("gjjt"==stepType){  //公交集团 除00 以外的
									   if("01"==row.step){
										    return "<td>物流审核中</td>"
									   }else if("02"==row.step){
									   		 return ' <div class="cl">'+
									   		 	'<span class="l">'+
									   		 	'<a style="text-decoration:none" href="javascript:;" onclick="report_workplan_update(\''+row.titleName+'\',\'report-workplan-report-update.html?companyId='+row.companyId+'&officeId='+row.officeId+'&serialNumber='+row.serialNumber+'\',\'\',\'1000\',\'500\')"  title="修改"><i class="Hui-iconfont">&#xe6df;</i></a></span>'+
									   		 '</div>'
									   }else if("03"==row.step){
										    //return "<td>发布</td>"
											return ' <div class="cl">'+
												'<span class="l">'+
												'<a style="text-decoration:none" href="javascript:;" onclick="report_workplan_update(\''+row.titleName+'\',\'report-workplan-report-update.html?companyId='+row.companyId+'&officeId='+row.officeId+'&serialNumber='+row.serialNumber+'\',\'\',\'1000\',\'500\')"  title="发布"><i class="Hui-iconfont">发布</i></a></span>'+
											'</div>'
									   }else if("97"==row.step){
										     return "<td>集团不通过</td>"
									   }else if("98"==row.step){
										     return "<td>物流不通过</td>"
									   }else{
										     return "<td>不通过</td>"
									   }
									   

								   }else if("company"==stepType){ //公交分公司 查看所有
				
										if("00"==row.step){
											return ' <div class="cl">'+
												'<span class="l">'+
													'<a style="text-decoration:none" href="javascript:;" onclick="report_workplan_update(\''+row.titleName+'\',\'report-workplan-report-update.html?companyId='+row.companyId+'&officeId='+row.officeId+'&serialNumber='+row.serialNumber+'\',\'\',\'1000\',\'500\')"  title="修改"><i class="Hui-iconfont">&#xe6df;</i></a></span>'+
											'</div>' 
										}else if("01"==row.step){
											return "<td>物流审核中</td>"
										}else if("02"==row.step){
											return "<td>集团审核中</td>"
										}else if("03"==row.step){
											return "<td>发布</td>"
											// return ' <div class="cl">'+
											// 	'<span class="l">'+
											// 	'<a style="text-decoration:none" href="javascript:;" onclick="report_workplan_update(\''+row.titleName+'\',\'report-workplan-report-update.html?companyId='+row.companyId+'&officeId='+row.officeId+'&serialNumber='+row.serialNumber+'\',\'\',\'1000\',\'500\')"  title="修改"><i class="Hui-iconfont">&#xe6df;</i></a></span>'+
											// '</div>' 
										}else if("97"==row.step){
											//return "<td>集团不通过</td>"
											return '<a style="text-decoration:none" href="javascript:;" onclick="report_workplan_update(\''+row.titleName+'\',\'report-workplan-report-update.html?companyId='+row.companyId+'&officeId='+row.officeId+'&serialNumber='+row.serialNumber+'\',\'\',\'1000\',\'500\')"  title="集团不通过"><i class="Hui-iconfont">集团不通过</i></a></span>'
											
										}else if("98"==row.step){
											//return "<td>物流不通过</td>"
											return '<a style="text-decoration:none" href="javascript:;" onclick="report_workplan_update(\''+row.titleName+'\',\'report-workplan-report-update.html?companyId='+row.companyId+'&officeId='+row.officeId+'&serialNumber='+row.serialNumber+'\',\'\',\'1000\',\'500\')"  title="物流不通过"><i class="Hui-iconfont">物流不通过</i></a></span>'
											
										}else{
											//return "<td>不通过</td>"
											return '<a style="text-decoration:none" href="javascript:;" onclick="report_workplan_update(\''+row.titleName+'\',\'report-workplan-report-update.html?companyId='+row.companyId+'&officeId='+row.officeId+'&serialNumber='+row.serialNumber+'\',\'\',\'1000\',\'500\')"  title="重新排班"><i class="Hui-iconfont">重排</i></a></span>'
											
										}
								   }else if("office"==stepType){
									   
									   if("3"==row.step){
										   return ' <div class="cl">'+
										   	'<span class="l">'+
										   		'<a style="text-decoration:none" href="javascript:;" onclick="report_workplan_update(\''+row.titleName+'\',\'report-workplan-report-update.html?companyId='+row.companyId+'&officeId='+row.officeId+'&serialNumber='+row.serialNumber+'\',\'\',\'1000\',\'500\')"  title="查看"><i class="Hui-iconfont">点击查看</i></a></span>'+
										   '</div>'
									   }
								   }else if("bjyh"==stepType){ // 北京银行
										if("01"==row.step){
											return "<td>物流审核中</td>"
										}else if("02"==row.step){
											return "<td>集团审核中</td>"
										}else if("03"==row.step){
											return "<td>发布</td>"
											// return ' <div class="cl">'+
											// 	'<span class="l">'+
											// 	'<a style="text-decoration:none" href="javascript:;" onclick="report_workplan_update(\''+row.titleName+'\',\'report-workplan-report-update.html?companyId='+row.companyId+'&officeId='+row.officeId+'&serialNumber='+row.serialNumber+'\',\'\',\'1000\',\'500\')"  title="修改"><i class="Hui-iconfont">&#xe6df;</i></a></span>'+
											// '</div>' 
										}else if("97"==row.step){
											return "<td>集团不通过</td>"
										}else if("98"==row.step){
											return "<td>物流不通过</td>"
										}else{
											return "<td>不通过</td>"
										}
								   }else if("dtwl"==stepType){ // 大田物流
									   if("01"==row.step){
											 return ' <div class="cl">'+
											 	'<span class="l">'+
											 	'<a style="text-decoration:none" href="javascript:;" onclick="report_workplan_update(\''+row.titleName+'\',\'report-workplan-report-update.html?companyId='+row.companyId+'&officeId='+row.officeId+'&serialNumber='+row.serialNumber+'\',\'\',\'1000\',\'500\')"  title="修改"><i class="Hui-iconfont">&#xe6df;</i></a></span>'+
											 '</div>' 
									   }else if("02"==row.step){
										    return "<td>集团审核中</td>"
									   }else if("03"==row.step){
											return "<td>发布</td>"
									   }else if("97"==row.step){
											return "<td>集团不通过</td>"
									   }else if("98"==row.step){
											return "<td>物流不通过</td>"
									   }else{
									   	return "<td>不通过</td>"
									   }
								   }
							   }
							}  ,
    						
    					],
						"order": [[ 1, "asc" ]],


						headerCallback: function(thead, data, start, end, display) {
							initHeader(thead,workPlanTitle,titleNums);
						},
    				   } ); 
					  // table.fnDestroy();
					   $("#list_length").attr("style","display:none;");
    	},
    	error:function(data) {
    		console.log(data.msg);
    	},
    });

}
	var isInitHeader = true;

function initHeader(thead,workPlanTitle,titleNums) {
	
	
	
		/* if(isInitHeader){
			isInitHeader = false;
		} else {
			return;
		} */
		
		var dateObj = (function(){
		  var _date = new Date();    // 默认为当前系统时间
		  return {
		    getDate : function(){
		      return _date;
		    },
		    setDate : function(date) {
		      _date = date;
		    }
		  };
		})();
		
		
		
		var tb = document.getElementById("list");
		var th = tb.getElementsByTagName("thead")
		var rows = [];
		
		function addRows(rIndex, cIndex, rowSpan, colSpan, text, fontSize) {
			var isNewRow = false;
			var isNewCol = false;
			var row = rows[rIndex];
			var col;
			
			if(row == undefined) {
				//生成表头
				row = document.createElement('tr');
				row.setAttribute('role', 'row');
				row.className="ccc"
				isNewRow = true;
				isNewCol = true;
			}
			if(cIndex == -1 || row.children[cIndex] == undefined){
				isNewCol = true;
			}
			//生成一个cell
			col = document.createElement('th');
			col.className = 'sorting_disabled';
			col.style='white-space: nowrap;'
			col.rowSpan = rowSpan != 0 ? rowSpan : 1;
			col.colSpan = colSpan != 0 ? colSpan : 1;
			col.style.textAlign = 'center';
			col.style.fontSize = fontSize != null ? fontSize : '12px';
			if(text=="id"){
				col.innerHTML='<input  class="check_item" id="checkboxId" onclick="selectAll(this)"   name="qrcodeid" type="checkbox" />'
				
			}else{
				col.innerHTML = text != null ? text : '';
			}
			
			row.appendChild(col);
			if(isNewCol) {
				row.appendChild(col);
			} else {
				row.replaceChild(col, row.children[cIndex]);
			}
			if(isNewRow) {
				rows.push(row);
			} else {
				rows[rIndex] = row;
			}
		}
		
		function appendRows(workPlanTitle) {
			for(var i = 0; i < rows.length; i ++) {
				thead.parentElement.insertBefore(rows[i], thead);
			}
		}
		
		if(workPlanTitle.companyName==null){
			workPlanTitle = {serialNumber:"序号",companyName:"公司",
			officeName:"票务室",receivablesTime:"接款时点",
			//rechargePointTransportationPlan:"充值点及特殊点位运输方案",
			rallyingPoint:"集结中心",remarks:"备注",receivablesTimeMonth:"审核原因",days:"31",
			titleName:"运输方案"
			};
			 //eval("param."+name+"="+val)
			
			
			var _year =dateObj.getDate().getFullYear();
			console.log(_year)
			var _month = dateObj.getDate().getMonth() + 1;
			console.log("==============="+_month)
			var day = new Date(_year,_month,0);
			console.log(day.getDate());  //31
			const weekDays = ['周日','周一','周二','周三','周四','周五','周六'];
			titleNums = day.getDate();
		
			
			var val = "";
			var dayi="";
			for(var i = 1; i <= day.getDate(); i++) {
				var day2 = new Date(_year,_month-1,i);
				const firstMonthDate = weekDays[day2.getDay()]
				 dayi = "day"+i;
				 val=firstMonthDate+","+i;
			//	 eval("workPlanTitle."+dayi+"="+val)
				 eval("workPlanTitle."+dayi+"='"+val+"'");
				// eval('('+"workPlanTitle."+dayi+"="+val+')');
			}
			
			
		}
		
		/* console.log(JSON.stringify(workPlanTitle))
		var titleNum =workPlanTitle.days;
		console.log(titleNum) */
		
		//console.log(Object.getOwnPropertyNames(workPlanTitle).length  )
		var titleName =  workPlanTitle.titleName;
		//var day = new Date(titleName.substring(0,4),titleName.substring(5,7),0);
		//titleNums = day.getDate();
		titleNums = parseInt(titleNums)+10
		titleName = titleName.substring(0,4)+"年"+titleName.substring(4,6)+"月";
		
		addRows(0, -1, 0, titleNums, titleName, ' 12px');
		
		addRows(1, -1, 2, 1, "id", ' 12px');
		addRows(1, -1, 2, 1, workPlanTitle.serialNumber, ' 12px');
		addRows(1, -1, 2, 1, workPlanTitle.companyName, ' 12px');
		addRows(1, -1, 2, 1, workPlanTitle.officeName, ' 12px');
		addRows(1, -1, 2, 1, "网点类型", ' 12px');
		//addRows(1, -1, 2, 1, workPlanTitle.receivablesTime, ' 12px');
		//addRows(1, -1, 2, 1, workPlanTitle.rechargePointTransportationPlan, ' 12px');
		addRows(1, -1, 2, 1, workPlanTitle.rallyingPoint, ' 12px');
		
		// 一组日期
		var day1 = workPlanTitle.day1;
		day1 = day1.split(",");
		addRows(1, -1, 0, 1, day1[0], '14px');
		addRows(2, -1, 0, 1, day1[1], '14px');
		
		var day2 = workPlanTitle.day2;
		day2 = day2.split(",");
		addRows(1, -1, 0, 1, day2[0], '14px');
		addRows(2, -1, 0, 1, day2[1], '14px');
		
		var day3 = workPlanTitle.day3;
		day3 = day3.split(",");
		addRows(1, -1, 0, 1, day3[0], '14px');
		addRows(2, -1, 0, 1, day3[1], '14px');
		
		var day4 = workPlanTitle.day4;
		day4 = day4.split(",");
		addRows(1, -1, 0, 1, day4[0], '14px');
		addRows(2, -1, 0, 1, day4[1], '14px');
		
		var day5 = workPlanTitle.day5;
		day5 = day5.split(",");
		addRows(1, -1, 0, 1, day5[0], '14px');
		addRows(2, -1, 0, 1, day5[1], '14px');
		
		var day6 = workPlanTitle.day6;
		day6 = day6.split(",");
		addRows(1, -1, 0, 1, day6[0], ' 12px');
		addRows(2, -1, 0, 1, day6[1], ' 12px');
		
		var day7 = workPlanTitle.day7;
		day7 = day7.split(",");
		addRows(1, -1, 0, 1, day7[0], ' 12px');
		addRows(2, -1, 0, 1, day7[1], ' 12px');
		
		var day8 = workPlanTitle.day8;
		day8 = day8.split(",");
		addRows(1, -1, 0, 1, day8[0], ' 12px');
		addRows(2, -1, 0, 1, day8[1], ' 12px');
		
		var day9 = workPlanTitle.day9;
		day9 = day9.split(",");
		addRows(1, -1, 0, 1, day9[0], ' 12px');
		addRows(2, -1, 0, 1, day9[1], ' 12px');
		
		var day10 = workPlanTitle.day10;
		day10 = day10.split(",");
		addRows(1, -1, 0, 1, day10[0], ' 12px');
		addRows(2, -1, 0, 1, day10[1], ' 12px');
		
		var day11 = workPlanTitle.day11;
		day11 = day11.split(",");
		addRows(1, -1, 0, 1, day11[0], ' 12px');
		addRows(2, -1, 0, 1, day11[1], ' 12px');
		
		var day12 = workPlanTitle.day12;
		day12 = day12.split(",");
		addRows(1, -1, 0, 1, day12[0], ' 12px');
		addRows(2, -1, 0, 1, day12[1], ' 12px');
		
		var day13 = workPlanTitle.day13;
		day13 = day13.split(",");
		addRows(1, -1, 0, 1, day13[0], ' 12px');
		addRows(2, -1, 0, 1, day13[1], ' 12px');
		
		var day14 = workPlanTitle.day14;
		day14 = day14.split(",");
		addRows(1, -1, 0, 1, day14[0], ' 12px');
		addRows(2, -1, 0, 1, day14[1], ' 12px');
		
		var day15 = workPlanTitle.day15;
		day15 = day15.split(",");
		addRows(1, -1, 0, 1, day15[0], ' 12px');
		addRows(2, -1, 0, 1, day15[1], ' 12px');
		
		var day16 = workPlanTitle.day16;
		day16 = day16.split(",");
		addRows(1, -1, 0, 1, day16[0], ' 12px');
		addRows(2, -1, 0, 1, day16[1], ' 12px');
		
		var day17 = workPlanTitle.day17;
		day17 = day17.split(",");
		addRows(1, -1, 0, 1, day17[0], ' 12px');
		addRows(2, -1, 0, 1, day17[1], ' 12px');
		
		var day18 = workPlanTitle.day18;
		day18 = day18.split(",");
		addRows(1, -1, 0, 1, day18[0], ' 12px');
		addRows(2, -1, 0, 1, day18[1], ' 12px');
		
		var day19 = workPlanTitle.day19;
		day19 = day19.split(",");
		addRows(1, -1, 0, 1, day19[0], ' 12px');
		addRows(2, -1, 0, 1, day19[1], ' 12px');
		
		var day20 = workPlanTitle.day20;
		day20 = day20.split(",");
		addRows(1, -1, 0, 1, day20[0], ' 12px');
		addRows(2, -1, 0, 1, day20[1], ' 12px');
		
		var day21 = workPlanTitle.day21;
		day21 = day21.split(",");
		addRows(1, -1, 0, 1, day21[0], ' 12px');
		addRows(2, -1, 0, 1, day21[1], ' 12px');
		
		var day22 = workPlanTitle.day22;
		day22 = day22.split(",");
		addRows(1, -1, 0, 1, day22[0], ' 12px');
		addRows(2, -1, 0, 1, day22[1], ' 12px');
		
		var day23 = workPlanTitle.day23;
		day23 = day23.split(",");
		addRows(1, -1, 0, 1, day23[0], ' 12px');
		addRows(2, -1, 0, 1, day23[1], ' 12px');
		
		var day24 = workPlanTitle.day24;
		day24 = day24.split(",");
		addRows(1, -1, 0, 1, day24[0], ' 12px');
		addRows(2, -1, 0, 1, day24[1], ' 12px');
		
		var day25 = workPlanTitle.day25;
		day25 = day25.split(",");
		addRows(1, -1, 0, 1, day25[0], ' 12px');
		addRows(2, -1, 0, 1, day25[1], ' 12px');
		
		var day26 = workPlanTitle.day26;
		day26 = day26.split(",");
		addRows(1, -1, 0, 1, day26[0], ' 12px');
		addRows(2, -1, 0, 1, day26[1], ' 12px');
		
		var day27 = workPlanTitle.day27;
		day27 = day27.split(",");
		addRows(1, -1, 0, 1, day27[0], ' 12px');
		addRows(2, -1, 0, 1, day27[1], ' 12px');
		
		var day28 = workPlanTitle.day28;
		day28 = day28.split(",");
		addRows(1, -1, 0, 1, day28[0], ' 12px');
		addRows(2, -1, 0, 1, day28[1], ' 12px');
		
		var yearNum = workPlanTitle.titleName.substring(0,4)
		var monthNum = workPlanTitle.titleName.substring(4,7)
		
		if(monthNum=="02"){
		　　if(yearNum%4==0&&yearNum%100!=0||yearNum%400==0){
				var day29 = workPlanTitle.day29;
				if(day29!=null&& typeof day29!=undefined){
					day29 = day29.split(",");
					addRows(1, -1, 0, 1, day29[0], ' 12px',false);
					addRows(2, -1, 0, 1, day29[1], ' 12px',false);
				}
					
		　　}else{
			console.log(111)
			
			addRows(1, -1, 0, 1, "", ' 12px');
			addRows(2, -1, 0, 1, "", ' 12px');
			addRows(1, -1, 0, 1, "", ' 12px');
			addRows(2, -1, 0, 1, "", ' 12px');
			addRows(1, -1, 0, 1, "", ' 12px');
			addRows(2, -1, 0, 1, "", ' 12px');
		}
		}else{
			var day29 = workPlanTitle.day29;
			if(day29!=null&& typeof day29!=undefined){
				day29 = day29.split(",");
				addRows(1, -1, 0, 1, day29[0], ' 12px');
				addRows(2, -1, 0, 1, day29[1], ' 12px');
			}
			
			
			var day30 = workPlanTitle.day30;
			if(day30!=null&& typeof day30!=undefined){
				day30 = day30.split(",");
				addRows(1, -1, 0, 1, day30[0], ' 12px');
				addRows(2, -1, 0, 1, day30[1], ' 12px');
			}
			
			var day31 = workPlanTitle.day31;
			if(day31!=null&& typeof day31!=undefined){
				day31 = day31.split(",");
				addRows(1, -1, 0, 1, day31[0], ' 12px');
				addRows(2, -1, 0, 1, day31[1], ' 12px');
			}else{
				addRows(1, -1, 0, 1, "", ' 12px');
				addRows(2, -1, 0, 1, "31", ' 12px');
			}
		}
		
		addRows(1, -1, 2, 1, workPlanTitle.receivablesTime, ' 12px');
		addRows(1, -1, 2, 1, workPlanTitle.remarks, ' 12px');
		//addRows(1, -1, 2, 1, workPlanTitle.receivablesTimeMonth, ' 12px');
		addRows(1, -1, 2, 1, "状态", ' 12px')
		appendRows(workPlanTitle);
		
		var cccList = document.getElementsByClassName("ccc")
		if(cccList.length>3){
			for(var f=cccList.length -1 ; f>=3;f--){
				var childs = cccList[f].childNodes;
				console.log(cccList[f])
				 for(var i = childs.length - 1; i >= 0; i--) { 
				  cccList[f].removeChild(childs[i]); 
				} 
			} 
		} 
		
	}
	function selectAll(obj) {
	  if (obj.checked) {
	    $(":checkbox").prop("checked", "checked");
	  } else {
	    $(":checkbox").removeProp("checked");
	  }
	}
	
	
	
	function excelExport(){
		var workPlan =$("#workPlan").val();
			layer.confirm('确认要导出当前数据？', function(index) {
				$("#list").table2excel({
							exclude: ".noExl",
							name: workPlan,
							filename:workPlan,
							exclude_img: true,
							exclude_links: true,
							exclude_inputs: true
						});
						 layer.close(layer.index)
			});
			
			
	}
	
	
	function processOnclick(){
		var companyId = $("#comId").val();
		var officeId =$("#toId").val();
		var workPlan =$("#workPlan").val();
				
		//onclick="report_workplan_update(\''+row.titleName+'\',\'report-workplan-report-update.html?companyId='+row.companyId+'&officeId='+row.officeId+'&serialNumber='+row.serialNumber+'\',\'\',\'1000\',\'500\')"
				title  ="流程参考";
				//url = "report-workplan-report-add.html?companyId="+companyId+"&officeId="+officeId+"";
				url = "report-workplan-report-process.html?companyId="+companyId+"&officeId="+officeId+"&workPlan="+workPlan+"";
				w = "650";
				h="290";
				layer_show_cr(title, url, w, h);
		
	}
	
	
	
	function updateByChecked(){
		var workPlan =$("#workPlan").val();
		var ids = "";
		var chk_value =[];
		$('input[name="qrcodeid"]:checked').each(function(){//遍历每一个名字为interest的复选框，其中选中的执行函数
			chk_value.push($(this).val());//将选中的值添加到数组chk_value中   
				ids=ids+$(this).val()+","
			});
			var stepWprl="";
			// if("gjjt"==stepType){  //公交集团 除00 以外的
			// 	stepWprl = "02"							   
			// }else if("bjyh"==stepType){ // 北京银行
			// 	stepWprl = "04"						
			// }else if("dtwl"==stepType){ // 大田物流
			// 	stepWprl = "03"						 
			// }else{
			// 	stepWprl = "01"		
			// }
			
			
			if("gjjt"==stepType){  //公交集团 除00 以外的
				stepWprl = "03"							   
			}else if("bjyh"==stepType){ // 北京银行
				stepWprl = "04"						
			}else if("dtwl"==stepType){ // 大田物流
				stepWprl = "02"						 
			}else{
				stepWprl = "01"		
			}
			
			
			if(ids==""){
				alert("选项不能为空")
				return;
			}
			
			layer.confirm('确认要提交？', function(index) {
					$.ajax({
						type: 'post',
						url:reportForm+'workPlan/updateByChecked',
						data: {
							serialNumber:ids,
							titleName:workPlan,
							step:stepWprl
						},
						dataType: 'json',
						success: function(data){
							var msg= data.msg;
							if(msg!="0"){
								alert("提交成功")
								 location.reload()
							}else{
								 location.reload()
							}
							//creationMonth(workPlanTitle,titleName);
						},
						error:function(data) {
							console.log(data.msg);
						},
					});
			});
			
			
	}
	

	
	function delByNumAndWorkPlanTitle(){
		var workPlan =$("#workPlan").val();
		var ids = "";
		var chk_value =[];
		$('input[name="qrcodeid"]:checked').each(function(){//遍历每一个名字为interest的复选框，其中选中的执行函数
			chk_value.push($(this).val());//将选中的值添加到数组chk_value中   
				ids=ids+$(this).val()+","
			});
			if(ids==""){
				alert("选项不能为空")
				return;
			}
			
			layer.confirm('确认要删除？', function(index) {
					$.ajax({
						type: 'post',
						url:reportForm+'workPlan/delByNumAndWorkPlanTitle',
						data: {
							serialNumber:ids,
							titleName:workPlan
						},
						dataType: 'json',
						success: function(data){
							var msg= data.msg;
							if(msg!="0"){
								alert("删除成功")
								 location.reload()
							}else{
								 location.reload()
							}
							//creationMonth(workPlanTitle,titleName);
						},
						error:function(data) {
							console.log(data.msg);
						},
					});
			});
			
			
			
	}
	
	
	
	function addByCompanyOffice(title, url, id, w, h) {
		var companyId = $("#comId").val();
		var officeId =$("#toId").val();
//onclick="report_workplan_update(\''+row.titleName+'\',\'report-workplan-report-update.html?companyId='+row.companyId+'&officeId='+row.officeId+'&serialNumber='+row.serialNumber+'\',\'\',\'1000\',\'500\')"
		title  ="新增运输计划";
		url = "report-workplan-report-add.html?companyId="+companyId+"&officeId="+officeId+"";
		w = "800";
		h ="510"
		layer_show_cr(title, url, w, h);
	} 
	function report_workplan_update(title, url, id, w, h) {
		layer_show_cr(title, url, w, h);
	} 
	function layer_show_cr(title,url,w,h){
		if (title == null || title == '') {
			title=false;
		};
		if (w == null || w == '') {
			w=800;
		};
		if (h == null || h == '') {
			h=($(window).height() - 50);
		};
		layer.open({
			type: 2,
			area: [w+'px', h +'px'],
			fix: false, //不固定
			maxmin: true,
			shade:0.4,
			title: title,
			content: url,
			end:function(){
				location.reload();
			}
		});
	}
	
	$("#comId").change(function(){
		$("#toId").empty();
		var comId = $(this).val();
		var targetUrl = report_service+'/getTicktOfficeByCom';
		if(comId == ''){
			//$("#toId").fadeOut("slow");
			return;
		}
		$.ajax({
			type: 'get',
			url: targetUrl,
			/* beforeSend: function (request) {
							request.setRequestHeader("Authorization", "Bearer " + getToken());
						}, */
			data:{
				"comId":comId
			},
			cache:false,    
			dataType:'json',  
			success: function(data){
				//var list = data.list;
				var list =  eval('(' + data.list + ')');
				var option2 = '<option value="">请选择票务室</option>';
				$("#toId").append(option2);
				for(var i=0;i<list.length;i++){
					var option = '<option value="'+list[i].toiid+'">'+list[i].toiname+'</option>';
					$("#toId").append(option);
				}
			},
			error:function(){
				alert("请求失败");
			}
		});
	});
</script>
</body>
</html>